<template>
  <h2>Login CallBack</h2>
</template>

<script lang="ts">

import { defineComponent } from "vue";
import { UserManager, Log } from "oidc-client";
import router from "@/router";

export default defineComponent({
  setup() {
    console.log("Sign in Redirect callback ...");
    // eslint-disable-next-line @typescript-eslint/camelcase
    const umgr = new UserManager({ response_mode: "query" });
    umgr.signinRedirectCallback().then(data => {
      Log.debug(`Window signin callback success`, data);

      const redirect = data.state ? data.state.to : null;
      if (router) router.replace(redirect || "/");
      else window.location.href = "/";
      });
  }
});
</script>
